package nc.bs.arap.bx.outer;

import java.util.ArrayList;
import java.util.List;

import nc.bs.arap.bx.BXZbBO;
import nc.bs.dao.BaseDAO;
import nc.vo.dap.pub.DapHookVO;
import nc.vo.dap.pub.DataPair;
import nc.vo.dap.pub.IDapHook;
import nc.vo.ep.bx.BXHeaderVO;
import nc.vo.pub.BusinessException;

/**
 * @author twei
 * 
 * nc.bs.arap.bx.outer.ErmForVoucherDel
 */
public class ErmForVoucherDel implements IDapHook {

	public String getModelID() {
		return null;
	}

	public void voucherDelete(DapHookVO hookvo)throws BusinessException {
		if(null==hookvo||hookvo.getBillInfo()==null||hookvo.getBillInfo().length==0)
			return ;
		DataPair<String, String>[] dp=hookvo.getBillInfo();
		List<String> zbpks=new ArrayList<String>();
		for(int i =0 ,size=dp.length;i<size;i++){
			String right = dp[i].getRight();
			if(right!=null && right.trim().length()==20) {
				if(!zbpks.contains(right))
					zbpks.add(right);
			}
		}
		List<BXHeaderVO> headers = new BXZbBO().queryHeadersByPrimaryKeys(zbpks.toArray(new String[]{}), "");
		
		if(headers==null || headers.size()==0)
			return ;
		
		for(BXHeaderVO head:headers){
			head.setJsh(null);
		}
		new BaseDAO().updateVOArray(headers.toArray(new BXHeaderVO[]{}), new String[]{BXHeaderVO.JSH});
	}
	
}
